home *** CD-ROM | disk | FTP | other *** search
- /*** main.c ***/
-
- /* CONTOUR Version 1.1 : Kenny K.H. Toh, Aug 28 1990 */
-
- #include <stdio.h>
- #include <strings.h>
- #include <math.h>
- #include "common.h"
- #include "contour.h"
- #include "plot.h"
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- extern int cont_out, expand;
-
- fprintf(stdout,"Contour V1.2 2/2/90\n");
- system("cat /home/mascot1/ktoh/SPLAT/SRC/Contour/README");
- initialize_data(); /* Initialize the variables */
- fileopen(argc,argv); /* read the data and options */
- if (expand) expand_cont(); /* Produce 3D surface */
- if (cont_out) draw_cont();
- else draw_view(argc,argv); /* draw the picture */
- fprintf(stdout,"Congratulations!!! You have been TERMINATED...\n");
- }
-
- /* Initialize some data */
- initialize_data()
- {
- char *getenv();
- char *strcpy();
- char *sprintf();
- extern char *term;
- extern char xlabel[MAXCHAR];
- extern char ylabel[MAXCHAR];
- extern char toplabel[MAXCHAR];
- extern char printer[MAXCHAR];
- extern int grid,equalscale,postscript,printplot;
- extern int xticks,yticks;
- extern int linetypes, contlabel, joincurve;
- extern int landscape;
- extern int cont_out;
- extern int expand;
- extern int oldformat;
- extern double scale;
-
- char *ptr;
-
- /* Terminal Type */
- term = getenv("TERM");
- fprintf(stdout," Terminal type = %s\n",term);
-
- /* Labeling information */
- strcpy(xlabel , "X-AXIS");
- strcpy(ylabel , "Y-AXIS");
- strcpy(toplabel , "CONTOUR PLOT");
-
- /* options */
- expand = OFF;
- cont_out = OFF;
- oldformat = OFF;
- joincurve = OFF;
-
- /* Plotting parameters/options */
- grid = OFF;
- equalscale = ON;
- postscript = ON;
- printplot = ON;
- contlabel = ON;
- landscape = OFF;
- linetypes = 2;
- scale = 1.00;
- xticks = 4;
- yticks = 4;
-
- /* list initialization */
- initialize_list();
-
- /* printer type */
- if ((ptr = getenv("PRINTER")) == NULL)
- strcpy(printer,"-Plp550M");
- else
- sprintf(printer,"-P%s",ptr);
- fprintf(stdout," Default Printer = %s\n",printer);
- }
-
- expand_cont()
- {
- FILE *fopen(), *fo;
- char *strcpy();
- extern triaptr tria_listhead;
- extern double xmin, xmax, ymin, ymax, zmin, zmax;
- char outputfile[MAXCHAR];
- int ncurves=0;
- triaptr T;
-
- /* prepare output file */
- strcpy(outputfile,imagefile);
- strcat(outputfile,".3D");
- if ((fo = fopen(outputfile,"w")) == NULL) {
- fprintf(stderr,"cat: can't open %s\n", outputfile);
- exit(1);
- }
-
- /* count the number of triangles */
- for (T=tria_listhead; T!=NULL; T=T->next) ncurves++;
-
- /* print out header - xmin,xmax,ymin,ymax,zmin,zmax,ncurves */
- fprintf(fo,"%10.5f %10.5f ",xmin,xmax);
- fprintf(fo,"%10.5f %10.5f ",ymin,ymax);
- fprintf(fo,"%10.5f %10.5f\n",zmin,zmax);
- fprintf(fo,"%10.5f\n",(double)ncurves);
-
- /* now print out the triangles */
- for (T=tria_listhead; T!=NULL; T=T->next) {
- fprintf(fo,"%10.5f\n",4.0);
- fprintf(fo,"%10.5f %10.5f %10.5f\n",T->pt1.x,T->pt1.y,T->pt1.z);
- fprintf(fo,"%10.5f %10.5f %10.5f\n",T->pt2.x,T->pt2.y,T->pt2.z);
- fprintf(fo,"%10.5f %10.5f %10.5f\n",T->pt3.x,T->pt3.y,T->pt3.z);
- fprintf(fo,"%10.5f %10.5f %10.5f\n",T->pt1.x,T->pt1.y,T->pt1.z);
- }
-
- /* now close the file */
- fclose(fo);
- fprintf(stdout," %d Triangles saved in \"%s\"\n",ncurves,outputfile);
- }
-